<?php /* Smarty version 2.6.26, created on 2013-06-11 15:22:28
         compiled from ddnpwarea_form_pat1.html */ ?>
<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
smarty_core_load_plugins(array('plugins' => array(array('modifier', 'escape', 'ddnpwarea_form_pat1.html', 298, false),array('modifier', 'number_format', 'ddnpwarea_form_pat1.html', 309, false),array('function', 'cycle', 'ddnpwarea_form_pat1.html', 343, false),)), $this); ?>
<?php echo '<?xml'; ?>
 version="1.0" encoding="utf-8"<?php echo '?>'; ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="ja" xml:lang="ja">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="Content-Script-Type" content="text/javascript" />
		<meta http-equiv="Content-Style-Type" content="text/css" />
		<title>コントロールパネル</title>
		<link rel="stylesheet" href="./assets/styles/default.css" type="text/css" />
		<link rel="stylesheet" href="./assets/styles/ui-lightness/ui.all.css" type="text/css" />
		<link rel="stylesheet" href="./assets/styles/ui-lightness/jquery-ui-1.7.3.custom.css" type="text/css" />
		<link rel="stylesheet" href="./assets/styles/dialog.css" type="text/css" />
		<script src="assets/scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
		<script src="assets/scripts/jquery-ui-1.7.3.custom.min.js" type="text/javascript"></script>
		<script src="assets/scripts/ui/ui.dialog.js" type="text/javascript"></script>
		<script src="assets/scripts/menu.js" type="text/javascript"></script>
		<script src="assets/scripts/table.js" type="text/javascript"></script>
		<script type="text/javascript" src="./tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
		<script type="text/javascript" src="./assets/scripts/editor.js"></script>
		<script type="text/javascript" src="./assets/scripts/ui/ui.datepicker.js"></script>
		<script type="text/javascript" src="./assets/scripts/ui/ui.core.js"></script>
		<script type="text/javascript" src="./assets/scripts/jquery.tablednd_0_5.js"></script>
		<script type="text/javascript" src="./assets/scripts/search.js"></script>
		<script type="text/javascript">
		$(function() {
			$('.message').fadeIn("slow");
			$('.btn_regist').click(function(){
				if( confirm('登録してよろしいですか？') ){
					document.fm.mode.value = 'input';
					document.fm.submit();
				}
			});
			$('.btn_update').click(function(){
				if( confirm('更新してよろしいですか？') ){
					document.fm.mode.value = 'input';
					document.fm.submit();
				}
			});
			$('.btn_return').click(function(){
				location.href = "ddnpwarea_index.php?hist=2";
			});
			
			$('button.tddel').live('click',function(){
				$(this).closest('tr').remove();
				add_to_sum();
			});
			/*
			$('input.nper').live('change',function(){
				var idarr = $(this).attr("id").split("_");
				var x;
				if ( $('#center_flg').is(':checked') ){
					x =  Math.round($(this).val() * ( $('#area_nums').val() *1  + $('#c_area_nums').val() * 1 ) / 100) ;
				} else {
					x =  Math.round($(this).val() * $('#area_nums').val() / 100) ;
				}
				$('#n_'+ idarr[1]).val(x);
				add_to_sum();
			});
			
			$('#title_cd').change(function(){
				var val = this.value;
				var valObj  = title_disp[val];
				var cdsul   = document.getElementsByName( 'shop_cd[]' );
				var shops   = "";

				if (valObj) {
					$.each(cdsul, function(i,val){
						shops =  shops + ","  + val.value  ;
						var mapid = "#mp_"  +   val.value ;
						$(mapid).val( ""); 
					}); 

					setmaps(shops ,valObj.sort );

				}else {
					$.each(cdsul, function(i,val){
						var mapid = "#mp_"  +   val.value ;
						$(mapid).val( ""); 
					}); 
				}
				
				if (title_disp[val]){
					$(".tsize").each(function() {
					   $(this).html(valObj.size);
					});
					$(".ttitle").each(function() {
					   $(this).html(valObj.title);
					});
					 gTitleName = valObj.title;
				     gTitleSize = valObj.size;
				     gTitleSort = valObj.sort;
				}else {
					$(".tsize").each(function() {
					   $(this).html("");
					});
					$(".ttitle").each(function() {
					   $(this).html("");
					});
					gTitleName = "";
					gTitleSize = "";
					gTitleSort = "";
				}
			});
			
			$('#year4').change(function(){
				var year4 = this.value;
				var myDate = new Date();
				var nowtime =  myDate.getTime();
					
				$.get("mmap_week_ajax.php",{ y: year4,t : nowtime }, function(data){
					$("#week_cd").children().remove();
					$("#week_cd").append( data ); 
				});
			});
			
			$('#area_nums').change(function(){
				changeshopnums();
			});
			$("#center_flg").change(function(){
				changeshopnums();
			});
			add_to_sum();
			*/
		});
		/*
	    function rObj(a1, a2,a3) {
	        this.size  = a1;
	        this.title = a2;
	        this.sort  = a3;
	    }
	    
	    var gTitleName = "<?php echo $this->_tpl_vars['forms']['title_name']; ?>
";
	    var gTitleSize = "<?php echo $this->_tpl_vars['forms']['title_size']; ?>
";
	    var gTitleSort = "<?php echo $this->_tpl_vars['forms']['title_sort']; ?>
";
	    
		var title_disp = new Array();
		<?php $_from = $this->_tpl_vars['titledata']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }$this->_foreach['member'] = array('total' => count($_from), 'iteration' => 0);
if ($this->_foreach['member']['total'] > 0):
    foreach ($_from as $this->_tpl_vars['kk'] => $this->_tpl_vars['vv']):
        $this->_foreach['member']['iteration']++;
?>
			title_disp["<?php echo $this->_tpl_vars['kk']; ?>
"] = new rObj("<?php echo $this->_tpl_vars['vv']['size']; ?>
", "<?php echo $this->_tpl_vars['vv']['titlecell']; ?>
","<?php echo $this->_tpl_vars['vv']['map']; ?>
" );
		<?php endforeach; endif; unset($_from); ?>
		
		function changeshopnums(){
			$('.nper').each(function(){
				var idarr = $(this).attr("id").split("_");
				var x;
				if ( $('#center_flg').is(':checked') ){
					x =  Math.round($(this).val() * ( $('#area_nums').val() *1  + $('#c_area_nums').val() * 1 ) / 100) ;
				} else {
					x =  Math.round($(this).val() * $('#area_nums').val() / 100) ;
				}
				
				$('#n_'+ idarr[1]).val(x);
			});
			add_to_sum();
		}
		
		function add_to_sum(){
			//パセント計算
			var psum = 0;
			$('.nper').each(function(){
				psum = psum +  $(this).val() *1;
			});
			$('#p_count').val(psum + "%");

			//部数計算
			var nsum = 0;
			$('.nnum').each(function(){
				nsum = nsum +  $(this).val() *1;
			});
			$('#n_count').val(nsum);
			
			var c_shop_nums =  $('#c_shop_nums').val() 
			var c_shop_per  =  $('#c_shop_per').val() ;
			
			if ($('#center_flg').is(':checked')){
				c_shop_nums = c_shop_nums * 1 + nsum;
				c_shop_per  = c_shop_per * 1 + psum;
			}
			$('#c_area_nums_txt').val( "( 都心エリア合計部数" + c_shop_nums+ " )" );
			$('#cp_count').val( "( " + c_shop_per+ "% )" );
			$('#cn_count').val( "( " + c_shop_nums + " )");
		}

		function setS( valnm ) {
			eval("document.fm." +  gPara + "_name.value ='" + valnm + "'");			
			$('#dialog').dialog("close");
		}
		
		function li_add(objID,inID, inVal,inSale) {
			
			if (checkNames(inID)) {
				var strHtml = "<li id='a" + inID +"' class='item_li'> <a href='#'  style='color:red' class='li_del' >X</a>&nbsp;&nbsp;"+ inID + "&nbsp;&nbsp;" + inVal;
					strHtml = strHtml + "<input type='hidden' value='" + inID  + "' name ='shop_cd_ul[]'>";
					strHtml = strHtml + "<input type='hidden' value='" + inVal + "' name ='shop_name_ul[]'>";
					strHtml = strHtml + "<input type='hidden' value='" + inSale + "' name ='shop_sale_ul[]'>";
					
				//if (typeof(g_shop_ul_to_grid)!="undefined") {
				//}
				strHtml = strHtml + "</li>";
				$("#" + objID +"_ul").append(strHtml);
			}
		}
		var g_shop_ul_to_grid = true ;
		function add_tr(vid, vname, vsale,vmapno) {
			var table = $('#table_shop');
			var str = '<tr><td> ' + vid + '</td><td>' + vname + ' </td>';
			str = str + '<td> <span class= "ttitle">' + gTitleName + '</span>  </td><td><span class="tsize">' + gTitleSize + ' </span> </td>';
			str = str + '<td> <input  id="mp_' +  vid + '" type="text" name="map_no[]" value="' + vmapno +'" class="dtext"  readonly style="width:85%"> </td>';
			str = str + '<td align=right>' + vsale + ' </td><td> <input type="text" id="p_'+ vid +'" name=shop_per[]" class="text nper" value = ""/> ';
			str = str + "<input type='hidden' value='" + vid  + "' name ='shop_cd[]'>";
			str = str + "<input type='hidden' value='" + vname + "' name ='shop_name[]'>";
			str = str + "<input type='hidden' value='" + vsale + "' name ='year_sale[]'>";
			//str = str + "<input type='hidden' value='" + vmapno + "' name ='map_no[]'>";
			str = str + '<td> <input type="text"  id="n_'+ vid +'"  name = shop_nums[]" class="text nnum"  readonly="readonly" value = ""/></td> '
			str = str + '<td align="center"><button type="button" class="tddel">削除</button> </td></tr>';
			
			$(table).append(str);
			var shops =  vid + ","   ;
			setmaps(shops , gTitleSort )
		}
		function setmaps(shops ,so ){
			var w = document.fm.w.value ;
			var pa = document.fm.pattern_cd.value ;
			var myDate = new Date();
			var nowtime =  myDate.getTime();
			$.get("ajax_dnpw_get_maps.php",{ w : w ,s : shops,so:so ,pa:pa , t : nowtime }, function(data){
				//var str   =  "002,888*" ;
				var smaps = data.split("*");
				for(i=0;i<smaps.length -1;i++){
					//var strnowmaps =  maps[i];
					var eachsmaps =  smaps[i].split(",");
					var mapid = "#mp_"  +  eachsmaps[0] ;
					$(mapid).val( eachsmaps[1] );
				} 
			});
		}
		function copy_shop_pop_ul_to_grid() {
			var cdsul   = document.getElementsByName( 'shop_cd_ul[]');
			var namesul = document.getElementsByName( 'shop_name_ul[]');
			var salesul = document.getElementsByName( 'shop_sale_ul[]');
			var cdarr   = new Array();
			$.each(cdsul, function(i,val){
				cdarr[i] = val.value;
			}); 
			var salearr   = new Array();
			$.each(salesul, function(i,val){
				salearr[i] = val.value;
			}); 
			
			var html = $("#table_shop tr:last").html();
			html = "<tr>" + html + "</tr>";
			$("#table_shop tr:last").remove();
			$.each(namesul, function(i,val){
				add_tr(cdarr[i], val.value, salearr[i])
			}); 
			$("#table_shop").append(html);
		}
		*/
		</script>
		
	</head>
	<body id="">
<?php echo $this->_tpl_vars['menu']; ?>

<?php echo $this->_tpl_vars['logout']; ?>

		<div id="container"><div class="wrapper">
			<h2>地域広告エリアマスター管理</h2>
			<ul class="submenu clearfix">
				<li>地域広告情報一覧．更新</li>
				 <li><a href = "ddnpwarea_update.php" >地域広告情報登録</a> </li>
				 <li><a href = "ddnparea_index.php" >DNPエリアマスタ</a></li>
			</ul>
			<h3>D地域広告情報<?php if ($this->_tpl_vars['forms']['id'] == ''): ?>登録<?php else: ?>更新<?php endif; ?><?php if ($this->_tpl_vars['phase'] == 'complete'): ?>完了<?php endif; ?></h3>
<?php if ($this->_tpl_vars['phase'] == 'input'): ?>
			<p class="message">内容を確認し、<?php if ($this->_tpl_vars['forms']['id'] == ''): ?>登録<?php else: ?>更新<?php endif; ?>ボタンをクリックしてください。</p>
			<form name="fm" action="ddnpwarea_form_pat1.php" method="post">
				<table class="formTable">
					<tbody>
<?php if ($this->_tpl_vars['forms']['id'] != ''): ?>
						<tr>
							<th>更新日</th>
							<td>
								<?php echo $this->_tpl_vars['forms']['u_time']; ?>
<input type="hidden" name="u_time" value="<?php echo $this->_tpl_vars['forms']['u_time']; ?>
" />
							</td>
						</tr>
						<tr>
							<th>更新者</th>
							<td>
								<?php echo $this->_tpl_vars['forms']['m_user_name']; ?>
<input type="hidden" name="m_user_name" value="<?php echo $this->_tpl_vars['forms']['m_user_name']; ?>
" />
							</td>
						</tr>
						<tr>
							<th>ID</th>
							<td><?php echo $this->_tpl_vars['forms']['id']; ?>
</td>
						</tr>
						<tr><th>※週名/折込日</th>
							<td>
								<input type="text" name="dispw" class="dtext" value="<?php echo ((is_array($_tmp=$this->_tpl_vars['forms']['dispw'])) ? $this->_run_mod_handler('escape', true, $_tmp) : smarty_modifier_escape($_tmp)); ?>
" readonly="readonly" />
								<input type="hidden" name="w"  value="<?php echo ((is_array($_tmp=$this->_tpl_vars['forms']['w'])) ? $this->_run_mod_handler('escape', true, $_tmp) : smarty_modifier_escape($_tmp)); ?>
" />
							</td>
						</tr>
<?php endif; ?>
						<tr><th>パターンコード</th>
						<td><?php echo $this->_tpl_vars['forms']['pattern_cd']; ?>
<input type="hidden" name="pattern_cd" value="<?php echo $this->_tpl_vars['forms']['pattern_cd']; ?>
" /></td>
						</tr><tr><th>新聞紙名</th>
						<td><?php echo $this->_tpl_vars['forms']['pattern_name']; ?>
<input type="hidden" name="pattern_name" value="<?php echo $this->_tpl_vars['forms']['pattern_name']; ?>
" /></td>
						</tr><tr>
							<th>※折込エリア部数</th>
							<td><?php echo ((is_array($_tmp=$this->_tpl_vars['forms']['area_nums'])) ? $this->_run_mod_handler('number_format', true, $_tmp) : number_format($_tmp)); ?>
 
							<input type="hidden" name="area_nums"value="<?php echo $this->_tpl_vars['forms']['sum_nums']; ?>
" readonly /></td>
						</tr>
						<tr>
							<th>※取扱業者</th>
							<td>
									<input type="text" name="hand_name" class="dtext" value="<?php echo ((is_array($_tmp=$this->_tpl_vars['forms']['hand_name'])) ? $this->_run_mod_handler('escape', true, $_tmp) : smarty_modifier_escape($_tmp)); ?>
" readonly/><?php echo $this->_tpl_vars['err']['hand_name']; ?>

									<input type="hidden" name="hand_cd"  value="<?php echo ((is_array($_tmp=$this->_tpl_vars['forms']['hand_cd'])) ? $this->_run_mod_handler('escape', true, $_tmp) : smarty_modifier_escape($_tmp)); ?>
" />
									<!-- <button type="button" id="hand" class="btn_search" rel="hand"><span>参照</span></button> -->
							</td>
						</tr><tr>
							<th>備考</th>
							<td>
								<textarea name="memo" class="textarea"  style="width:380px" /><?php echo $this->_tpl_vars['forms']['memo']; ?>
</textarea>
							</td>
						</tr>

					</tbody>
				</table>
<p class="button">実施版一覧</p>
			<table id="search_result" class="formTable" >
				<thead>
					<tr><th>セールタイトル</th>
						<th>サイズ</th>
						<th>MAP</th>
						<th>店舗数</th>
						<th>店舗部数合計</th>
						<th>販売店</th>
						<th>更新</th>
					</tr>
				</thead>
				<tbody>
<?php $_from = $this->_tpl_vars['data']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }$this->_foreach['member'] = array('total' => count($_from), 'iteration' => 0);
if ($this->_foreach['member']['total'] > 0):
    foreach ($_from as $this->_tpl_vars['k'] => $this->_tpl_vars['v']):
        $this->_foreach['member']['iteration']++;
?>
		<?php if ($this->_tpl_vars['v']['title_name']): ?>
				<tr class="<?php echo smarty_function_cycle(array('values' => "odd,mod",'name' => 'member'), $this);?>
">
					<td><?php echo $this->_tpl_vars['v']['title_name']; ?>
</td>
					<td><?php echo $this->_tpl_vars['v']['size']; ?>
</td>
					<td><?php echo $this->_tpl_vars['v']['isirgyu']; ?>
</td>
					<td align=right><?php echo ((is_array($_tmp=$this->_tpl_vars['v']['shop_cnt'])) ? $this->_run_mod_handler('number_format', true, $_tmp) : number_format($_tmp)); ?>
</td>
					<td align=right><?php echo ((is_array($_tmp=$this->_tpl_vars['v']['shop_nums'])) ? $this->_run_mod_handler('number_format', true, $_tmp) : number_format($_tmp)); ?>
</td>
					<td align=right><?php echo $this->_tpl_vars['v']['ins_nums']; ?>
件</td>
					<td class="center" ><a href="ddnpwarea_form_pat2.php?id=<?php echo $this->_tpl_vars['v']['id']; ?>
&p=<?php echo $this->_tpl_vars['forms']['pattern_cd']; ?>
&w=<?php echo $this->_tpl_vars['forms']['matrix_cd']; ?>
">[更新]</a></td>
				</tr>
		<?php endif; ?>
<?php endforeach; endif; unset($_from); ?>
<tr><td>合計</td><td></td><td></td><td align=right> <?php echo ((is_array($_tmp=$this->_tpl_vars['forms']['sum_shops'])) ? $this->_run_mod_handler('number_format', true, $_tmp) : number_format($_tmp)); ?>
 </td><td align=right> <?php echo ((is_array($_tmp=$this->_tpl_vars['forms']['sum_nums'])) ? $this->_run_mod_handler('number_format', true, $_tmp) : number_format($_tmp)); ?>
</td><td align=right><?php echo ((is_array($_tmp=$this->_tpl_vars['forms']['ins_nums'])) ? $this->_run_mod_handler('number_format', true, $_tmp) : number_format($_tmp)); ?>
件</td><td></td>
</tr>
				</tbody>
			</table>
				<p class="button">
				<button type="button" class="btn_return" class="submit"><span>戻る</span></button>
<?php if ($this->_tpl_vars['forms']['id'] != ''): ?>
					<button type="button" class="btn_update" class="submit"><span>更新</span></button>
<?php else: ?>
					<button type="button" class="btn_regist" class="submit"><span>登録</span></button>
<?php endif; ?>
				</p>
				<input type="hidden" name="id" value="<?php echo $this->_tpl_vars['forms']['id']; ?>
" />
				<input type="hidden" name="isshop" value="<?php echo $this->_tpl_vars['isshop']; ?>
" />
				<input type="hidden" name="mode" value="" />
			</form>
<div id="dialog" >
</div>
 <div id="dialogmuti" >
</div>
<?php endif; ?>
<a href="ddnpwarea_form_pat2.php?p=<?php echo $this->_tpl_vars['forms']['pattern_cd']; ?>
&w=<?php echo $this->_tpl_vars['forms']['w']; ?>
">[セールタイトルを追加する]</a>
<?php if ($this->_tpl_vars['phase'] == 'complete'): ?>
			<p class="message"><?php echo $this->_tpl_vars['message']; ?>
</p>
			<ul>
<?php if ($this->_tpl_vars['forms']['id'] != ''): ?>
				<li>>> <a href="ddnpwarea_index.php?hist=2">一覧ページに戻る</a></li>
<?php else: ?>
				<li>>> <a href="ddnpwarea_index.php">一覧ページに戻る</a></li>
<?php endif; ?>
<?php if ($this->_tpl_vars['forms']['id'] != ''): ?>
				<li>>> <a href="ddnpwarea_form_pat1.php?id=<?php echo $this->_tpl_vars['forms']['id']; ?>
&p=<?php echo $this->_tpl_vars['forms']['pattern_cd']; ?>
&w=<?php echo $this->_tpl_vars['forms']['w']; ?>
">更新</a></li>
<?php endif; ?>
			</ul>
<?php endif; ?>
		</div></div>
		<?php echo $this->_tpl_vars['footer']; ?>

	</body>
</html>